﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BTN04.DTO;
using BTN04.BUS;

namespace BTN04.GUEST
{
    public partial class TimKiemSanPham : System.Web.UI.Page
    {
        private SanPhamCrt spCrt = new SanPhamCrt();
        private string tensanpham;
        private int malsp;
        private float giatu;
        private float giaden;
        public void Update()
        {
            if (tensanpham == "Nhập tên cần tìm" || tensanpham == "")
                spCrt.ChkTen = false;
            else
            {
                spCrt.TenSanPham = tensanpham;
                spCrt.ChkTen = true;
            }
            spCrt.MaLoaiSanPham = malsp;
            if (spCrt.MaLoaiSanPham != 0)
            {
                spCrt.ChkLoaiSanPham = true;
            }
            if (giatu != 0 && giaden != 0)
            {
                spCrt.GiaTu = giatu;
                spCrt.GiaDen = giaden;
                spCrt.ChkGia = true;
            }
            else
            {
                spCrt.GiaTu = 0;
                spCrt.GiaDen = 0;
                spCrt.ChkGia = false;
            }
        }

        public DataTable TimKiemThuong()
        {
            tensanpham = Session["tensanpham"].ToString();
            malsp = int.Parse(Session["malsp"].ToString());
            try
            {
                giatu = float.Parse(Session["giatu"].ToString());
                giaden = float.Parse(Session["giaden"].ToString());
            }
            catch
            {
                giatu = 0;
                giaden = 0;
            }
           

            Update();
            SanPhamBUS spBUS = new SanPhamBUS();

            DataTable dt = new DataTable();
            dt = spBUS.TimKiemThuong(spCrt);
            return dt;


        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }


    }
}
